<!DOCTYPE HTML>
<html>
<head>
  <title>店铺审核管理</title>
  <link rel="stylesheet" href="/stylesheets/style.css">
  <script src="/scripts/jquery.min.js"></script>
  <script src="/scripts/boot.js" type="text/javascript"></script>
  <link rel="stylesheet" href="/scripts/miniui/themes/default/miniui.css">
  <link rel="stylesheet" href="/scripts/miniui/themes/icons.css">
  <link rel="stylesheet" href="/scripts/miniui/themes/bootstrap/skin.css">
  <link rel="stylesheet" href="/editor/common.css">
  <script src="/scripts/miniui/miniui.js"></script>
</head>
<body  style="padding: 0;width: 100%;height: 97%">
<div style="width:99%;height: 97%;">
  <div id="outImg">
    <img id="imgId" src="" alt="" onclick="smallImg()">
  </div>
  <div style="padding: 5px">
    <span>申请人ID：</span><input class="mini-textbox" type="text" id="verifyUserID"/>
    <span>申请人：</span><input  class="mini-textbox" type="text" id="verifyUserName"/>
    <span>身份证号：</span><input  class="mini-textbox" type="text" id="verifyUserIdentityCardNo"/>
    <span>申请人电话：</span><input  class="mini-textbox" type="text" id="verifyUserTel"/>
    <span>审核状态：</span><input  class="mini-combobox" type="text" id="shopStatus" value="-1" data="verifyStatus"/>
    <input style="margin-right: 30px" type="button" value="查找" onclick="search()"/>
  </div>
  <div style="width:99%;">
    <div class="mini-toolbar" style="border-bottom:0;padding:0px;">
      <table style="width:100%;">
        <tr>
          <td style="width:100%;">
            <a class="mini-button" iconCls="icon-edit" onclick="verifyStatusEdit()">编辑</a>
          </td>
        </tr>
      </table>
    </div>
  </div>
  <div id="datagrid1" class="mini-datagrid" style="width:99%;height: 97%;"
       url="/getdata/shopVerifyManger" idField="id" allowResize="true" onselectionchanged="onSelectionChanged"
       sizeList="[20,30,50,100]" pageSize="20">
    <div property="columns">
      <div type="checkcolumn" width="20" ></div>
      <div field="objectId" width="90" align="center" headerAlign="center">审核ID</div>
      <div field="userOId" width="90" align="center" headerAlign="center">申请人ID</div>
      <div field="name" width="40" align="center" headerAlign="center">申请人</div>
      <div field="identityCardNo" width="80" align="center" headerAlign="center">身份证号</div>
      <div field="holdIdentityCard"  width="30" align="center" headerAlign="center">手持身份证</div>
      <div field="tel" width="60" align="center" headerAlign="center">申请人电话</div>
      <div field="shopStatus" width="40" align="center" headerAlign="center">审核状态</div>
      <div field="reason" width="40" align="center" headerAlign="center">审核备注</div>
      <div name="action" width="40" headerAlign="center" align="center" renderer="onActionRenderer" cellStyle="padding:0;">操作</div>
      <div field="createdAt" width="60" renderer="onBirthdayRenderer" align="center" headerAlign="center">创建日期</div>
      <div field="updatedAt" width="60" renderer="onBirthdayRenderer" align="center" headerAlign="center">更新日期</div>

    </div>
  </div>
</div>
</body>
<script type="text/javascript">
  var flag = 1;
  var verifyStatus = [{ id: -1, text: ' ' },{ id: 0, text: '未审核' },{ id: 1, text: '审核成功' },{ id: 2, text: '审核失败' }, { id: 3, text: '审核中'}];
  mini.parse();
  var grid = mini.get("datagrid1");
  grid.load({shopStatus:'3'});
  grid.on("drawcell", function (e) {
    var value = e.value;
    var column = e.column;
    if (column.field == "holdIdentityCard") {
      if(value) {
        e.cellHtml = '<img class="bigImg" onclick="bigImg()" src="' + value + '?imageMogr2/thumbnail/640x/format/jpg/interlace/1/auto-orient" width="30" height="30" alt="图片">';
      }else{
        e.cellHtml = '<img class="bigImg" onclick="bigImg()"  src="http://7xiuo5.com1.z0.glb.clouddn.com/fgImage.png?imageMogr2/auto-orient/thumbnail/!100x100r/gravity/Center/crop/100x100/quality/80/auto-orient" width="30" height="30" alt="图片">';
      }
    }
    if (column.field == "shopStatus") {
      parseInt(value)
      if(value == 0) {
        e.cellHtml = '<text>未审核</text>';
      }else if(value == 1) {
        e.cellHtml = '<text>审核成功</text>';
      }else if(value == 2) {
        e.cellHtml = '<text>审核失败</text>';
      }else if(value == 3) {
        e.cellHtml = '<text>审核中</text>';

      }
    }
  });
  function search() {
    var verifyUserID = mini.get("verifyUserID").getValue();
    var verifyUserName = mini.get("verifyUserName").getValue();
    var verifyUserIdentityCardNo = mini.get("verifyUserIdentityCardNo").getValue();
    var verifyUserTel = mini.get("verifyUserTel").getValue();
    var shopStatus = mini.get("shopStatus").getValue();
    if (verifyUserID=="" && verifyUserName=="" && verifyUserIdentityCardNo=="" && verifyUserTel=="" && shopStatus=="") {
      alert('请输入查询条件！')
    } else {
      grid.load({
        verifyUserID: verifyUserID,
        verifyUserName:verifyUserName,
        verifyUserIdentityCardNo:verifyUserIdentityCardNo,
        verifyUserTel:verifyUserTel,
        shopStatus:shopStatus
      });
    }
  }
//  function searchStatus() {
//    var status = mini.get("status").getValue();
//    grid.load({
//      status: status
//    });
//  }
  $("#verifyUserID,#verifyUserName,#verifyUserIdentityCardNo,#verifyUserTel,#shopStatus").bind("keydown", function (e) {
    if (e.keyCode == 13) {
      search();
    }
  });

  function bigImg() {
    var row = grid.getSelected();
    if (row) {
      if(flag==1) {
        var path = row.holdIdentityCard;
        $("#imgId").attr('src', path);
        $("#outImg").css('display','block');
      }
    }
  }
  function bigImgCode() {
    var row = grid.getSelected();
    if (row) {
      if(flag==1) {
        var path = row.qrCode;
        $("#imgId").attr('src', path);
        $("#outImg").css('display','block');
      }
    }
  }
  function smallImg() {
    $("#outImg").css('display','none');
  }


  function onBirthdayRenderer(e) {
    var value = e.value;
    if (value) return mini.formatDate(value, 'yyyy-MM-dd hh:mm:ss');
    return "";
  };

  function onSelectionChanged(e) {
    var tribeGrid = e.sender;
//    tribeGrid.setStyle('height: 52%;');
//    grid2.setStyle('height: 47%;');
    var record = tribeGrid.getSelected();
    if (record) {
      tribeOId = record.objectId;
      tribeName = record.name;
//      grid2.load({tribeOId:record.objectId});
    }
  }
  function verifyStatusEdit() {
    var data = {};
    var row = grid.getSelected();
    if (row){
      var objectId = row.objectId;
      var userOId = row.userOId;
      var name = row.name;
      var identityCardNo = row.identityCardNo;
      var shopStatus = row.shopStatus;
      var tel = row.tel;
      data.objectId = objectId;
      data.userOId = userOId;
      data.name = name;
      data.identityCardNo = identityCardNo;
      data.shopStatus = shopStatus;
      data.tel = tel;
    } else {
      alert("请选中一行!");
      return;
    };
//    console.log(data);
    mini.open({
      url: "/getdata/shopVerifyMangerEdit",
      title: "编辑审核状态", width: 600, height: 220,
      onload: function () {
        var iframe = this.getIFrameEl();
//          var datas = { action: "sort", id: row.id };
        iframe.contentWindow.SetData(data);
      },
      ondestroy: function (action) {
        grid.reload();
      }
    });
  };
  function onActionRenderer(e) {
    var grid = e.sender;
    var record = e.record;
    var uid = record._uid;
    var shopStatus = record.shopStatus;
    var rowIndex = e.rowIndex;
    var s;
    if (shopStatus == '3'){
      s = '<a class="Edit_Button" href="javascript:permit(\'' + uid + '\')">通过</a> '
        + '<a class="Delete_Button" href="javascript:refuse(\'' + uid + '\')">拒绝</a> ';
    }
    return s;
  };
  function permit(row_uid) {
    var row = grid.getRowByUID(row_uid);
    if (row) {
//      console.log(row);
      var data = {};
      var objectId = row.objectId;
      var userOId = row.userOId;
      data.objectId = objectId;
      data.userOId = userOId;
      data.shopStatus = '1';
      data.reason = '审核通过';
      $.ajax({
        url: "/getdata/shopVerifyMangerEditHandle",
        type: 'post',
        data: data,
        cache: false,
        success: function (res) {
          var resultData = JSON.parse(res);
          alert(resultData);
          grid.reload();
        },
        error: function (error) {
          console.log(error)
        }
      });
    }
  };
  function refuse(row_uid) {
    var row = grid.getRowByUID(row_uid);
    if (row) {
//      console.log(row);
      var data = {};
      var objectId = row.objectId;
      var userOId = row.userOId;
      var name = row.name;
      var identityCardNo = row.identityCardNo;
      var shopStatus = row.shopStatus;
      var tel = row.tel;
      var reason = row.reason;
      data.objectId = objectId;
      data.userOId = userOId;
      data.name = name;
      data.identityCardNo = identityCardNo;
      data.shopStatus = shopStatus;
      data.tel = tel;
      data.reason = reason;
      mini.open({
        url: "/getdata/shopVerifyMangerRefuse",
        title: "店铺审核未通过", width: 600, height: 220,
        onload: function () {
          var iframe = this.getIFrameEl();
          iframe.contentWindow.SetData(data);
        },
        ondestroy: function (action) {
          grid.reload();
        }
      });
    }
  };
</script>
</html>
